package com.dalei.vds;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;

public class WelcomeActivity extends Activity {
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		WelcomeView view = new WelcomeView(this);
		setContentView(view);
		
		Handler handler = new Handler();
		handler.postDelayed(new Runnable() {
			
			public void run() {
				// TODO Auto-generated method stub
				Intent intent = new Intent();
				intent.setClass(WelcomeActivity.this, LoginActivity.class);
				WelcomeActivity.this.startActivity(intent);
				WelcomeActivity.this.finish();
			}
		}, 3000);
	}
	
	@SuppressLint("DrawAllocation")
	private class WelcomeView extends View {
		
		public WelcomeView(Context context) {
			super(context);
			// TODO Auto-generated constructor stub
		}
		
		@Override
		protected void onDraw(Canvas canvas) {
			// TODO Auto-generated method stub
			super.onDraw(canvas);
			Paint paint = new Paint();
			paint.setAntiAlias(true);
			Bitmap img = BitmapFactory.decodeResource(getResources(), R.drawable.welcome);
			canvas.drawBitmap(img, 0, 0, paint);
			paint.setColor(Color.YELLOW);
			paint.setTextSize(20);
			canvas.drawText(getResources().getString(R.string.version_value), 280, 460, paint);
		}
	}
}
